package views.others;


import java.util.LinkedHashMap;
import java.util.Map;

import views.slidingMenu.R;
import views.slidingMenu.R.id;
import views.slidingMenu.R.layout;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class LazyAdapter extends BaseAdapter {
    
    private Activity activity;
    LinkedHashMap<Integer,Object[]> menu_button_text;
    
    private static LayoutInflater inflater=null;
  //  public ImageLoader imageLoader; 
    /**
     * @param menu_button_test
     * integer -> position in menu list
     * Object[]->string title and int Resourceid for icon
     */
    public LazyAdapter(Activity a, LinkedHashMap<Integer,Object[]>menu_button_text) {
        activity = a;
        this.menu_button_text = menu_button_text;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    public int getCount() {
        return menu_button_text.size();
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }
    
    public View getView(int position, View convertView, ViewGroup parent) {
        View vi=convertView;
        if(convertView==null)
            vi = inflater.inflate(R.layout.item, null);
        TextView text=(TextView)vi.findViewById(R.id.text);;
        ImageView image=(ImageView)vi.findViewById(R.id.image);
        text.setText((String)menu_button_text.get(position+1)[1]);
       image.setImageResource((Integer) menu_button_text.get(position+1)[0]);
        return vi;
    }
}